#ifndef CVX_DXUT_FRAME_H
#define CVX_DXUT_FRAME_H 1

//dxut framework: mouse, keyboard etc

#include "cvxDxut.h"
#include "cvxD3d9.h"
#include "nv_stereo_utils.h"
#include "cvxSurface.h"



class ExpData;
class ExpImagePos;

struct KeyBoardControl
{
	vector<int> _buf;   //all key board input
	char _curInput;
	bool _inputError;
	bool _finish;
	bool _isPeak;      //isPeak be set?

	KeyBoardControl()
	{
		_inputError = false;
		_finish = false;
		_isPeak = true;
	}

};

class CvxDxutFrame
{

public:
	static CDXUTDialogResourceManager  s_dialogResourceManager;
	static CDXUTDialog                 s_hud;                  // dialog for standard controls
	static CDXUTDialog                 s_sampleUI;
	static CDXUTTextHelper*            s_pTxtHelper;

	static ID3DXFont*                  s_pFont9;	
	static ID3DXSprite*                s_pSprite9;

	static CvxStereoSurface *          s_pStereoSurface;
	static CvxCursorSurface *          s_pCursor;
	
	static ExpImagePos          *      s_pExpImagePos; 
	static bool                        s_isFullScreen;
	static KeyBoardControl  *          s_keyBuffer;

	//two button
	static CDXUTButton*                s_pPeakButton;
	static CDXUTButton*                s_pValleyButton;


public:
	static void InitApp();
	static void RenderText();
	static void RenderKeyboardHint();
	static void RenderImageCount(int num, int totalNum);
	static void RenderExpConfiguration(bool isStereo, bool isSquare, bool isCaustic, char pOrv);
	static void RenderThanks();
	static void saveResult();

	static int Width();
	static int Height();

	static LRESULT CALLBACK MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool* pbNoFurtherProcessing,
									 void* pUserContext );

	static void CALLBACK OnKeyboard( UINT nChar, bool bKeyDown, bool bAltDown, void* pUserContext );
	static void CALLBACK OnMouse( bool bLeftButtonDown, bool bRightButtonDown, bool bMiddleButtonDown, 
								  bool bSideButton1Down, bool bSideButton2Down, int nMouseWheelDelta, int xPos, int yPos, void* pUserContext );

	
	static void CALLBACK OnD3D9FrameRender( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext );

	static void CALLBACK OnFrameMove( double fTime, float fElapsedTime, void* pUserContext );



	static  bool CALLBACK IsD3D9DeviceAcceptable( D3DCAPS9* pCaps, D3DFORMAT AdapterFormat,
								D3DFORMAT BackBufferFormat, bool bWindowed, void* pUserContext );

	static HRESULT CALLBACK OnD3D9CreateDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc,
										void* pUserContext );
	static HRESULT CALLBACK OnD3D9ResetDevice( IDirect3DDevice9* pd3dDevice,
								const D3DSURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext );


	static void CALLBACK OnD3D9DestroyDevice( void* pUserContext);

	static void CALLBACK OnD3D9LostDevice( void* pUserContext );

	static void CALLBACK OnGUIEvent( UINT nEvent, int nControlID, CDXUTControl* pControl, void* pUserContext );



};


#endif